﻿Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data

Public Class DataProdList


    Public Function populateArray() As List(Of Product)
        Dim prdList As New List(Of Product)
        Dim cnt As Integer = 0
        Dim Command As New SqlCommand()
        Command.Connection = Data.OpenDatabase()
        Command.CommandText = "SELECT * FROM Product;"
        Dim Table As New DataTable()
        Table.Load(Command.ExecuteReader())

        If Table.Rows.Count > 0 Then
            For Each Row As DataRow In Table.Rows
                'productID
                'productDesc
                'productPrice
                'productCategoryID <=======NOT implemented
                'productNotes
                Dim prd As New Product
                prd.setpID(Convert.ToInt32(Row.Item("productID")))
                prd.setpDesc(Row.Item("productDesc").ToString())
                prd.setpPrc(Convert.ToDouble(Row.Item("productPrice")))
                prd.setpNotes(Row.Item("productNotes").ToString())
                prdList.Add(prd)
            Next
        End If
        Return prdList
    End Function
End Class
